<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增终端库')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-library-add">
            <div class="form-group">
                <label class="col-sm-3 control-label  is-required">品牌名称：</label>
                <div class="col-sm-8">
                    <input name="manuName" onclick="selectModel()" readonly id="manuName" type="text" class="form-control" required>
                    <i class="fa fa-search" style="margin-top: -22px;margin-right:3px;float:right;"></i>
                </div>
            </div>
            <input name="id" id="id" type="hidden">
            <div class="form-group">
                <label class="col-sm-3 control-label  is-required">终端型号：</label>
                <div class="col-sm-8">
                    <input name="model"  readonly id="model" type="text" class="form-control" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">生成数量：</label>
                <div class="col-sm-8">
                    <input name="count" class="form-control" type="number" required>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "terminal/library"
        $("#form-library-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                var cout = Number($("input[name='count']").val());
                if( cout > '10000'){
                    $.modal.msgError("生成密钥的数量不得多于1万条!");
                    return;
                }
                $.operate.save(prefix + "/add", $('#form-library-add').serialize(), function(result) {
                    if (result.code == web_status.SUCCESS) {
                        $.modal.alertSuccess(result.msg);
                        //window.location.href = ctx + "common/download?fileName=" + encodeURI(result.msg) + "&delete=" + true;
                    } else if (result.code == web_status.WARNING) {
                        $.modal.alertWarning(result.msg)
                    } else {
                        $.modal.alertError(result.msg);
                    }
                });
            }
        }
        function selectModel() {
            var url = ctx + "terminal/model/selectModel/";
            $.modal.open("选择型号" , url, '700');
        }
    </script>
</body>
</html>